package com.yunchang.springboot.utils.mwsutils;

import com.yunchang.springboot.utils.DateUtil;
import org.apache.commons.lang3.StringUtils;

import java.text.ParseException;

public class GetYesterdayByDate {
    /**
     * 根据 date 判断是否为八点之前，是则取date前一天的日期，否的话则取当前日期
     * @param date
     * @return
     */
    public static  String getWarehouseDate(String date) throws ParseException {
        if(StringUtils.isEmpty(date)){
            return "";
        }
        String warehouseDate;
        String standardReturnDate = date.substring(0,10) + " 08:00:00";
        Integer dateResult = DateUtil.compateTime(date, standardReturnDate);
        if(1 ==  dateResult || 0 ==  dateResult ){
            warehouseDate = date.substring(0,10);
        }else {
            warehouseDate = DateUtil.dateToFutureDate(date.substring(0,10),-1);
        }
        return warehouseDate;
    }
}
